/**
 * RoleUserDaoImpl.java
 * Created at 2017-07-06
 * Created by Jackie liu
 * Copyright (C) 2014, All rights reserved.
 */
package com.huabo.dao.impl.oracle;

import com.huabo.base.BaseDaoImpl;
import com.huabo.dao.inter.RoleUserDao;
import com.huabo.model.RoleUser;
import com.huabo.sql.builder.WhereBuilder;
import org.springframework.stereotype.Repository;

/**
 * <p>ClassName: RoleUserDaoImpl</p>
 * <p>Description: 用户角色关系Dao实现</p>
 * <p>Author: Jackie liu</p>
 * <p>Date: 2017-07-06</p>
 */
@Repository
public class RoleUserDaoImpl extends BaseDaoImpl<RoleUser, Long> implements RoleUserDao {

    @Override
    public int deleteByUserId(Long userId) {
        if (userId == null) {
            return 0;
        }

        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("F_USER_ID", userId);
        return deleteByCondition(wb);
    }

    @Override
    public int delete(Long userId, Long roleId) {
        if (userId == null || roleId == null) {
            return 0;
        }
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("F_USER_ID", userId);
        wb.andEquals("F_ROLE_ID", roleId);
        return deleteByCondition(wb);
    }
}